<?php
#注册插件
RegisterPlugin("CommentSet","ActivePlugin_CommentSet");
function ActivePlugin_CommentSet() {
	Add_Filter_Plugin('Filter_Plugin_PostComment_Core','CommentSet_Main');
	Add_Filter_Plugin('Filter_Plugin_ViewPost_Template','CommentSet_Plus');
}
function CommentSet_Main(&$cmt) {
	global $zbp;
	if(!$zbp->user->ID){
		$cmt->IsThrow = TRUE;
		$zbp->lang['error'][14] = '提交失败，未登录或会员级别不够！';
		$zbp->ShowError(14, __FILE__, __LINE__);
	}
}
function CommentSet_Plus(&$template){
	global $zbp;
	$article = $template->GetTags('article');
	if(isset($article->ID) && $zbp->user->Level > $zbp->Config('CommentSet')->level){
		if(!$zbp->user->ID){
			$zbp->footer .= '<div id="nocmtip" style="position:absolute;left:-100%;height:0;overflow:hidden;">'.$zbp->Config('CommentSet')->showtip.'</div>' . "\r\n";
		}else{
			$zbp->footer .= '<div id="nocmtip" style="position:absolute;left:-100%;height:0;overflow:hidden;">您所属会员级别暂无权限发表评论！</div>' . "\r\n";
		}
		$zbp->footer .= '<script src="'.$zbp->host.'zb_users/plugin/CommentSet/c.js"></script>' . "\r\n";
	}
}
//安装插件
function InstallPlugin_CommentSet() {
	global $zbp;
	//配置初始化
	if (!$zbp->Config('CommentSet')->HasKey('version')) {
		$zbp->Config('CommentSet')->version = '1.0';
		$zbp->Config('CommentSet')->level="5";
		$zbp->Config('CommentSet')->showtip='请先 <a href="javascript:;" class="xylogin">登录</a> 再评论，若不是会员请先 <a href="javascript:;" class="xyreg">注册</a>！';
		$zbp->SaveConfig('CommentSet');
	}
}
//卸载插件
function UninstallPlugin_CommentSet() {
	global $zbp;
	//$zbp->DelConfig('CommentSet');
}